{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "07817843-ce54-4c82-a434-5067d990418a",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-09-24T05:33:04.633070Z",
     "iopub.status.busy": "2024-09-24T05:33:04.632676Z",
     "iopub.status.idle": "2024-09-24T05:33:04.638934Z",
     "shell.execute_reply": "2024-09-24T05:33:04.638482Z",
     "shell.execute_reply.started": "2024-09-24T05:33:04.633039Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[Errno 2] No such file or directory: 'demo'\n",
      "/mnt/workspace\n"
     ]
    }
   ],
   "source": [
    "%cd demo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "507c9105-b622-4021-80d6-2d71f64d44a3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-09-24T05:33:08.827191Z",
     "iopub.status.busy": "2024-09-24T05:33:08.826872Z",
     "iopub.status.idle": "2024-09-24T05:33:12.078977Z",
     "shell.execute_reply": "2024-09-24T05:33:12.078426Z",
     "shell.execute_reply.started": "2024-09-24T05:33:08.827171Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "正克隆到 'SenseVoice'...\n",
      "remote: Enumerating objects: 337, done.\u001b[K\n",
      "remote: Counting objects: 100% (138/138), done.\u001b[K\n",
      "remote: Compressing objects: 100% (75/75), done.\u001b[K\n",
      "remote: Total 337 (delta 99), reused 79 (delta 63), pack-reused 199 (from 1)\u001b[K\n",
      "接收对象中: 100% (337/337), 6.60 MiB | 4.05 MiB/s, 完成.\n",
      "处理 delta 中: 100% (201/201), 完成.\n"
     ]
    }
   ],
   "source": [
    "!git clone https://github.com/FunAudioLLM/SenseVoice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "646bccc4-bb5e-4cdd-b57c-0f9342ba9aa3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-09-24T05:33:14.143463Z",
     "iopub.status.busy": "2024-09-24T05:33:14.143098Z",
     "iopub.status.idle": "2024-09-24T05:33:14.147261Z",
     "shell.execute_reply": "2024-09-24T05:33:14.146782Z",
     "shell.execute_reply.started": "2024-09-24T05:33:14.143438Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/mnt/workspace/SenseVoice\n"
     ]
    }
   ],
   "source": [
    "%cd SenseVoice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d87440bf-5ae5-4eff-bac9-84925a52d8c5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-09-24T05:33:21.394530Z",
     "iopub.status.busy": "2024-09-24T05:33:21.394220Z",
     "iopub.status.idle": "2024-09-24T05:33:52.682313Z",
     "shell.execute_reply": "2024-09-24T05:33:52.681725Z",
     "shell.execute_reply.started": "2024-09-24T05:33:21.394511Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://mirrors.cloud.aliyuncs.com/pypi/simple\n",
      "Collecting torch<=2.3\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/43/e5/2ddae60ae999b224aceb74490abeb885ee118227f866cb12046f0481d4c9/torch-2.3.0-cp310-cp310-manylinux1_x86_64.whl (779.1 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m779.1/779.1 MB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: torchaudio in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 2)) (2.3.0+cpu)\n",
      "Requirement already satisfied: modelscope in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 3)) (1.18.0)\n",
      "Collecting huggingface\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/f4/8c/e61fbc39c0a37140e1d4941c4af29e2d53bacf9f4559e3de24d8f4e484f0/huggingface-0.0.1-py3-none-any.whl (2.5 kB)\n",
      "Requirement already satisfied: huggingface_hub in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 5)) (0.24.2)\n",
      "Requirement already satisfied: funasr>=1.1.3 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 6)) (1.1.6)\n",
      "Requirement already satisfied: numpy<=1.26.4 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 7)) (1.26.4)\n",
      "Collecting gradio\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/00/ce/9c969f7c591c21cd0f419b6cd95273cdcd4efbc6dce3b75b619b821d71fb/gradio-4.44.0-py3-none-any.whl (18.1 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.1/18.1 MB\u001b[0m \u001b[31m115.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: fastapi>=0.111.1 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 9)) (0.111.1)\n",
      "Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (12.1.105)\n",
      "Requirement already satisfied: filelock in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (3.14.0)\n",
      "Requirement already satisfied: nvidia-cudnn-cu12==8.9.2.26 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (8.9.2.26)\n",
      "Collecting triton==2.3.0\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/db/ee/8d50d44ed5b63677bb387f4ee67a7dbaaded0189b320ffe82685a6827728/triton-2.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (168.1 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m168.1/168.1 MB\u001b[0m \u001b[31m18.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (12.1.105)\n",
      "Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (12.1.0.106)\n",
      "Requirement already satisfied: typing-extensions>=4.8.0 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (4.12.0)\n",
      "Requirement already satisfied: sympy in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (1.12.1)\n",
      "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (2024.5.0)\n",
      "Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (10.3.2.106)\n",
      "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (3.1.4)\n",
      "Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (11.4.5.107)\n",
      "Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (12.1.105)\n",
      "Requirement already satisfied: nvidia-nccl-cu12==2.20.5 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (2.20.5)\n",
      "Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (12.1.3.1)\n",
      "Requirement already satisfied: networkx in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (3.3)\n",
      "Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (11.0.2.54)\n",
      "Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch<=2.3->-r requirements.txt (line 1)) (12.1.105)\n",
      "Requirement already satisfied: nvidia-nvjitlink-cu12 in /usr/local/lib/python3.10/site-packages (from nvidia-cusolver-cu12==11.4.5.107->torch<=2.3->-r requirements.txt (line 1)) (12.6.68)\n",
      "Requirement already satisfied: tqdm>=4.64.0 in /usr/local/lib/python3.10/site-packages (from modelscope->-r requirements.txt (line 3)) (4.66.4)\n",
      "Requirement already satisfied: requests>=2.25 in /usr/local/lib/python3.10/site-packages (from modelscope->-r requirements.txt (line 3)) (2.32.3)\n",
      "Requirement already satisfied: urllib3>=1.26 in /usr/local/lib/python3.10/site-packages (from modelscope->-r requirements.txt (line 3)) (2.2.1)\n",
      "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/site-packages (from huggingface_hub->-r requirements.txt (line 5)) (24.0)\n",
      "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/site-packages (from huggingface_hub->-r requirements.txt (line 5)) (6.0.1)\n",
      "Requirement already satisfied: scipy>=1.4.1 in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (1.12.0)\n",
      "Requirement already satisfied: jaconv in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.4.0)\n",
      "Requirement already satisfied: soundfile>=0.12.1 in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.12.1)\n",
      "Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.2.0)\n",
      "Requirement already satisfied: umap-learn in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.5.6)\n",
      "Requirement already satisfied: jamo in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.4.1)\n",
      "Requirement already satisfied: jieba in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.42.1)\n",
      "Requirement already satisfied: editdistance>=0.5.2 in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.5.2)\n",
      "Requirement already satisfied: librosa in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.10.2.post1)\n",
      "Requirement already satisfied: kaldiio>=2.17.0 in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (2.18.0)\n",
      "Requirement already satisfied: torch-complex in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.4.4)\n",
      "Requirement already satisfied: hydra-core>=1.3.2 in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (1.3.2)\n",
      "Requirement already satisfied: tensorboardX in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (2.6.2.2)\n",
      "Requirement already satisfied: pytorch-wpe in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (0.0.1)\n",
      "Requirement already satisfied: oss2 in /usr/local/lib/python3.10/site-packages (from funasr>=1.1.3->-r requirements.txt (line 6)) (2.18.6)\n",
      "Requirement already satisfied: pydantic>=2.0 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (2.7.2)\n",
      "Collecting ffmpy\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/ff/1e/db99aa669eee301966bc6c997d60a0240f9cecae63f044b2e5a5310e4bf7/ffmpy-0.4.0-py3-none-any.whl (5.8 kB)\n",
      "Collecting gradio-client==1.3.0\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/de/fe/7e9cb4d0e6aa74268fa31089189e4855882a0f2a36c45d359336946d4ae1/gradio_client-1.3.0-py3-none-any.whl (318 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m318.7/318.7 kB\u001b[0m \u001b[31m22.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: python-multipart>=0.0.9 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (0.0.9)\n",
      "Requirement already satisfied: pillow<11.0,>=8.0 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (10.3.0)\n",
      "Requirement already satisfied: typer<1.0,>=0.12 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (0.12.3)\n",
      "Collecting tomlkit==0.12.0\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/68/4f/12207897848a653d03ebbf6775a29d949408ded5f99b2d87198bc5c93508/tomlkit-0.12.0-py3-none-any.whl (37 kB)\n",
      "Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (2.1.5)\n",
      "Collecting importlib-resources<7.0,>=1.3\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/e1/6a/4604f9ae2fa62ef47b9de2fa5ad599589d28c9fd1d335f32759813dfa91e/importlib_resources-6.4.5-py3-none-any.whl (36 kB)\n",
      "Collecting pydub\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/a6/53/d78dc063216e62fc55f6b2eebb447f6a4b0a59f55c8406376f76bf959b08/pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n",
      "Collecting aiofiles<24.0,>=22.0\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/c5/19/5af6804c4cc0fed83f47bff6e413a98a36618e7d40185cd36e69737f3b0e/aiofiles-23.2.1-py3-none-any.whl (15 kB)\n",
      "Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (3.9.0)\n",
      "Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (4.4.0)\n",
      "Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (2.2.2)\n",
      "Requirement already satisfied: uvicorn>=0.14.0 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (0.30.3)\n",
      "Requirement already satisfied: httpx>=0.24.1 in /usr/local/lib/python3.10/site-packages (from gradio->-r requirements.txt (line 8)) (0.27.0)\n",
      "Collecting semantic-version~=2.0\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/6a/23/8146aad7d88f4fcb3a6218f41a60f6c2d4e3a72de72da1825dc7c8f7877c/semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n",
      "Collecting orjson~=3.0\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/b6/bc/fbd345d771a73cacc5b0e774d034cd081590b336754c511f4ead9fdc4cf1/orjson-3.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m141.9/141.9 kB\u001b[0m \u001b[31m14.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hCollecting ruff>=0.2.2\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/9f/55/53f10c1bd8c3b2ae79aed18e62b22c6346f9296aa0ec80489b8442bd06a9/ruff-0.6.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.8 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.8/10.8 MB\u001b[0m \u001b[31m125.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: websockets<13.0,>=10.0 in /usr/local/lib/python3.10/site-packages (from gradio-client==1.3.0->gradio->-r requirements.txt (line 8)) (12.0)\n",
      "Requirement already satisfied: fastapi-cli>=0.0.2 in /usr/local/lib/python3.10/site-packages (from fastapi>=0.111.1->-r requirements.txt (line 9)) (0.0.4)\n",
      "Requirement already satisfied: email_validator>=2.0.0 in /usr/local/lib/python3.10/site-packages (from fastapi>=0.111.1->-r requirements.txt (line 9)) (2.2.0)\n",
      "Requirement already satisfied: starlette<0.38.0,>=0.37.2 in /usr/local/lib/python3.10/site-packages (from fastapi>=0.111.1->-r requirements.txt (line 9)) (0.37.2)\n",
      "Requirement already satisfied: exceptiongroup>=1.0.2 in /usr/local/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio->-r requirements.txt (line 8)) (1.2.1)\n",
      "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio->-r requirements.txt (line 8)) (3.7)\n",
      "Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio->-r requirements.txt (line 8)) (1.3.1)\n",
      "Requirement already satisfied: dnspython>=2.0.0 in /usr/local/lib/python3.10/site-packages (from email_validator>=2.0.0->fastapi>=0.111.1->-r requirements.txt (line 9)) (2.3.0)\n",
      "Requirement already satisfied: certifi in /usr/local/lib/python3.10/site-packages (from httpx>=0.24.1->gradio->-r requirements.txt (line 8)) (2024.2.2)\n",
      "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/site-packages (from httpx>=0.24.1->gradio->-r requirements.txt (line 8)) (1.0.5)\n",
      "Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/site-packages (from httpcore==1.*->httpx>=0.24.1->gradio->-r requirements.txt (line 8)) (0.14.0)\n",
      "Requirement already satisfied: omegaconf<2.4,>=2.2 in /usr/local/lib/python3.10/site-packages (from hydra-core>=1.3.2->funasr>=1.1.3->-r requirements.txt (line 6)) (2.3.0)\n",
      "Requirement already satisfied: antlr4-python3-runtime==4.9.* in /usr/local/lib/python3.10/site-packages (from hydra-core>=1.3.2->funasr>=1.1.3->-r requirements.txt (line 6)) (4.9.3)\n",
      "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio->-r requirements.txt (line 8)) (4.53.0)\n",
      "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio->-r requirements.txt (line 8)) (1.2.1)\n",
      "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio->-r requirements.txt (line 8)) (2.9.0.post0)\n",
      "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio->-r requirements.txt (line 8)) (0.12.1)\n",
      "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio->-r requirements.txt (line 8)) (1.4.5)\n",
      "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio->-r requirements.txt (line 8)) (3.1.2)\n",
      "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/site-packages (from pandas<3.0,>=1.0->gradio->-r requirements.txt (line 8)) (2024.1)\n",
      "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/site-packages (from pandas<3.0,>=1.0->gradio->-r requirements.txt (line 8)) (2024.1)\n",
      "Requirement already satisfied: pydantic-core==2.18.3 in /usr/local/lib/python3.10/site-packages (from pydantic>=2.0->gradio->-r requirements.txt (line 8)) (2.18.3)\n",
      "Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/site-packages (from pydantic>=2.0->gradio->-r requirements.txt (line 8)) (0.7.0)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/site-packages (from requests>=2.25->modelscope->-r requirements.txt (line 3)) (3.3.2)\n",
      "Requirement already satisfied: cffi>=1.0 in /usr/local/lib/python3.10/site-packages (from soundfile>=0.12.1->funasr>=1.1.3->-r requirements.txt (line 6)) (1.16.0)\n",
      "Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio->-r requirements.txt (line 8)) (8.1.7)\n",
      "Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio->-r requirements.txt (line 8)) (13.7.1)\n",
      "Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio->-r requirements.txt (line 8)) (1.5.4)\n",
      "Requirement already satisfied: python-dotenv>=0.13 in /usr/local/lib/python3.10/site-packages (from uvicorn>=0.14.0->gradio->-r requirements.txt (line 8)) (1.0.1)\n",
      "Requirement already satisfied: httptools>=0.5.0 in /usr/local/lib/python3.10/site-packages (from uvicorn>=0.14.0->gradio->-r requirements.txt (line 8)) (0.6.1)\n",
      "Requirement already satisfied: watchfiles>=0.13 in /usr/local/lib/python3.10/site-packages (from uvicorn>=0.14.0->gradio->-r requirements.txt (line 8)) (0.22.0)\n",
      "Requirement already satisfied: uvloop!=0.15.0,!=0.15.1,>=0.14.0 in /usr/local/lib/python3.10/site-packages (from uvicorn>=0.14.0->gradio->-r requirements.txt (line 8)) (0.19.0)\n",
      "Requirement already satisfied: numba>=0.51.0 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (0.60.0)\n",
      "Requirement already satisfied: soxr>=0.3.2 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (0.4.0)\n",
      "Requirement already satisfied: audioread>=2.1.9 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (3.0.1)\n",
      "Requirement already satisfied: scikit-learn>=0.20.0 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (1.5.0)\n",
      "Requirement already satisfied: pooch>=1.1 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (1.8.2)\n",
      "Requirement already satisfied: joblib>=0.14 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (1.4.2)\n",
      "Requirement already satisfied: msgpack>=1.0 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (1.0.8)\n",
      "Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (4.4.2)\n",
      "Requirement already satisfied: lazy-loader>=0.1 in /usr/local/lib/python3.10/site-packages (from librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (0.4)\n",
      "Requirement already satisfied: pycryptodome>=3.4.7 in /usr/local/lib/python3.10/site-packages (from oss2->funasr>=1.1.3->-r requirements.txt (line 6)) (3.20.0)\n",
      "Requirement already satisfied: crcmod>=1.7 in /usr/local/lib/python3.10/site-packages (from oss2->funasr>=1.1.3->-r requirements.txt (line 6)) (1.7)\n",
      "Requirement already satisfied: aliyun-python-sdk-kms>=2.4.1 in /usr/local/lib/python3.10/site-packages (from oss2->funasr>=1.1.3->-r requirements.txt (line 6)) (2.16.3)\n",
      "Requirement already satisfied: aliyun-python-sdk-core>=2.13.12 in /usr/local/lib/python3.10/site-packages (from oss2->funasr>=1.1.3->-r requirements.txt (line 6)) (2.15.1)\n",
      "Requirement already satisfied: six in /usr/local/lib/python3.10/site-packages (from oss2->funasr>=1.1.3->-r requirements.txt (line 6)) (1.16.0)\n",
      "Requirement already satisfied: mpmath<1.4.0,>=1.1.0 in /usr/local/lib/python3.10/site-packages (from sympy->torch<=2.3->-r requirements.txt (line 1)) (1.3.0)\n",
      "Requirement already satisfied: protobuf>=3.20 in /usr/local/lib/python3.10/site-packages (from tensorboardX->funasr>=1.1.3->-r requirements.txt (line 6)) (3.20.3)\n",
      "Requirement already satisfied: pynndescent>=0.5 in /usr/local/lib/python3.10/site-packages (from umap-learn->funasr>=1.1.3->-r requirements.txt (line 6)) (0.5.13)\n",
      "Requirement already satisfied: jmespath<1.0.0,>=0.9.3 in /usr/local/lib/python3.10/site-packages (from aliyun-python-sdk-core>=2.13.12->oss2->funasr>=1.1.3->-r requirements.txt (line 6)) (0.10.0)\n",
      "Requirement already satisfied: cryptography>=2.6.0 in /usr/local/lib/python3.10/site-packages (from aliyun-python-sdk-core>=2.13.12->oss2->funasr>=1.1.3->-r requirements.txt (line 6)) (43.0.0)\n",
      "Requirement already satisfied: pycparser in /usr/local/lib/python3.10/site-packages (from cffi>=1.0->soundfile>=0.12.1->funasr>=1.1.3->-r requirements.txt (line 6)) (2.22)\n",
      "Requirement already satisfied: llvmlite<0.44,>=0.43.0dev0 in /usr/local/lib/python3.10/site-packages (from numba>=0.51.0->librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (0.43.0)\n",
      "Requirement already satisfied: platformdirs>=2.5.0 in /usr/local/lib/python3.10/site-packages (from pooch>=1.1->librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (4.2.2)\n",
      "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio->-r requirements.txt (line 8)) (3.0.0)\n",
      "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio->-r requirements.txt (line 8)) (2.18.0)\n",
      "Requirement already satisfied: threadpoolctl>=3.1.0 in /usr/local/lib/python3.10/site-packages (from scikit-learn>=0.20.0->librosa->funasr>=1.1.3->-r requirements.txt (line 6)) (3.5.0)\n",
      "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio->-r requirements.txt (line 8)) (0.1.2)\n",
      "Installing collected packages: pydub, huggingface, triton, tomlkit, semantic-version, ruff, orjson, importlib-resources, ffmpy, aiofiles, torch, gradio-client, gradio\n",
      "  Attempting uninstall: triton\n",
      "    Found existing installation: triton 2.3.1\n",
      "    Uninstalling triton-2.3.1:\n",
      "      Successfully uninstalled triton-2.3.1\n",
      "  Attempting uninstall: torch\n",
      "    Found existing installation: torch 2.3.1\n",
      "    Uninstalling torch-2.3.1:\n",
      "      Successfully uninstalled torch-2.3.1\n",
      "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
      "torchvision 0.18.1 requires torch==2.3.1, but you have torch 2.3.0 which is incompatible.\n",
      "pai-easycv 0.11.6 requires timm==0.5.4, but you have timm 1.0.9 which is incompatible.\n",
      "optimum 1.21.4 requires transformers[sentencepiece]<4.44.0,>=4.29.0, but you have transformers 4.45.0.dev0 which is incompatible.\n",
      "fairseq 0.12.2 requires hydra-core<1.1,>=1.0.7, but you have hydra-core 1.3.2 which is incompatible.\n",
      "fairseq 0.12.2 requires omegaconf<2.1, but you have omegaconf 2.3.0 which is incompatible.\n",
      "easyrobust 0.2.4 requires timm==0.5.4, but you have timm 1.0.9 which is incompatible.\n",
      "autoawq 0.2.6 requires torch==2.3.1, but you have torch 2.3.0 which is incompatible.\n",
      "autoawq-kernels 0.0.7 requires torch==2.3.1, but you have torch 2.3.0 which is incompatible.\u001b[0m\u001b[31m\n",
      "\u001b[0mSuccessfully installed aiofiles-23.2.1 ffmpy-0.4.0 gradio-4.44.0 gradio-client-1.3.0 huggingface-0.0.1 importlib-resources-6.4.5 orjson-3.10.7 pydub-0.25.1 ruff-0.6.7 semantic-version-2.10.0 tomlkit-0.12.0 torch-2.3.0 triton-2.3.0\n",
      "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
      "\u001b[0m\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.2\u001b[0m\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install -r requirements.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "801424f6-d6eb-42c3-8cbf-510bf15ece03",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-09-24T05:35:58.389845Z",
     "iopub.status.busy": "2024-09-24T05:35:58.389526Z",
     "iopub.status.idle": "2024-09-24T05:36:27.660533Z",
     "shell.execute_reply": "2024-09-24T05:36:27.659998Z",
     "shell.execute_reply.started": "2024-09-24T05:35:58.389823Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "funasr version: 1.1.6.\n",
      "Check update of funasr, and it would cost few times. You may disable it by set `disable_update=True` in AutoModel\n",
      "You are using the latest version of funasr-1.1.6\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-09-24 13:36:07,209 - modelscope - WARNING - Using branch: master as version is unstable, use with caution\n",
      "Downloading [example/.DS_Store]: 100%|██████████| 6.00k/6.00k [00:00<00:00, 11.2kB/s]\n",
      "Downloading [fig/aed_figure.png]: 100%|██████████| 116k/116k [00:00<00:00, 210kB/s]\n",
      "Downloading [am.mvn]: 100%|██████████| 10.9k/10.9k [00:00<00:00, 28.0kB/s]\n",
      "Downloading [fig/asr_results.png]: 100%|██████████| 238k/238k [00:00<00:00, 380kB/s]\n",
      "Downloading [chn_jpn_yue_eng_ko_spectok.bpe.model]: 100%|██████████| 368k/368k [00:00<00:00, 589kB/s]\n",
      "Downloading [config.yaml]: 100%|██████████| 1.81k/1.81k [00:00<00:00, 3.64kB/s]\n",
      "Downloading [configuration.json]: 100%|██████████| 396/396 [00:00<00:00, 974B/s]\n",
      "Downloading [example/en.mp3]: 100%|██████████| 56.1k/56.1k [00:00<00:00, 146kB/s]\n",
      "Downloading [fig/inference.png]: 100%|██████████| 935k/935k [00:00<00:00, 1.63MB/s]\n",
      "Downloading [example/ja.mp3]: 100%|██████████| 56.5k/56.5k [00:00<00:00, 115kB/s]\n",
      "Downloading [example/ko.mp3]: 100%|██████████| 27.3k/27.3k [00:00<00:00, 52.9kB/s]\n",
      "Downloading [model.pt]: 100%|██████████| 893M/893M [00:02<00:00, 326MB/s]  \n",
      "Downloading [README.md]: 100%|██████████| 9.09k/9.09k [00:00<00:00, 20.4kB/s]\n",
      "Downloading [fig/sensevoice.png]: 100%|██████████| 880k/880k [00:00<00:00, 1.35MB/s]\n",
      "Downloading [fig/ser_figure.png]: 100%|██████████| 194k/194k [00:00<00:00, 382kB/s]\n",
      "Downloading [fig/ser_table.png]: 100%|██████████| 318k/318k [00:00<00:00, 606kB/s]\n",
      "Downloading [example/yue.mp3]: 100%|██████████| 30.5k/30.5k [00:00<00:00, 49.4kB/s]\n",
      "Downloading [example/zh.mp3]: 100%|██████████| 43.9k/43.9k [00:00<00:00, 70.8kB/s]\n",
      "2024-09-24 13:36:24,036 - modelscope - WARNING - Using branch: master as version is unstable, use with caution\n",
      "Downloading [am.mvn]: 100%|██████████| 7.85k/7.85k [00:00<00:00, 20.7kB/s]\n",
      "Downloading [config.yaml]: 100%|██████████| 1.19k/1.19k [00:00<00:00, 3.00kB/s]\n",
      "Downloading [configuration.json]: 100%|██████████| 365/365 [00:00<00:00, 889B/s]\n",
      "Downloading [model.pt]: 100%|██████████| 1.64M/1.64M [00:00<00:00, 3.89MB/s]\n",
      "Downloading [README.md]: 100%|██████████| 10.6k/10.6k [00:00<00:00, 18.4kB/s]\n",
      "Downloading [fig/struct.png]: 100%|██████████| 27.3k/27.3k [00:00<00:00, 56.8kB/s]\n",
      "Downloading [example/vad_example.wav]: 100%|██████████| 2.16M/2.16M [00:00<00:00, 3.99MB/s]\n"
     ]
    }
   ],
   "source": [
    "from funasr import AutoModel\n",
    "from funasr.utils.postprocess_utils import rich_transcription_postprocess\n",
    "\n",
    "model_dir = \"iic/SenseVoiceSmall\"\n",
    "\n",
    "\n",
    "model = AutoModel(\n",
    "    model=model_dir,\n",
    "    vad_model=\"fsmn-vad\",\n",
    "    vad_kwargs={\"max_single_segment_time\": 30000},\n",
    "    device=\"cuda:0\",\n",
    "    # hub=\"hf\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "a7f72982-af27-4de6-a299-ffdbbf811d32",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-09-24T05:37:20.066024Z",
     "iopub.status.busy": "2024-09-24T05:37:20.065565Z",
     "iopub.status.idle": "2024-09-24T05:37:21.846205Z",
     "shell.execute_reply": "2024-09-24T05:37:21.845677Z",
     "shell.execute_reply.started": "2024-09-24T05:37:20.066000Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "rtf_avg: 0.007: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.93it/s]                                                                                          \n",
      "  0%|\u001b[31m          \u001b[0m| 0/1 [00:00<?, ?it/s]\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  3.18it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.006', 'forward': '0.314', 'batch_size': '1', 'rtf': '0.051'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  3.18it/s]\u001b[A\n",
      "rtf_avg: 0.051: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  3.15it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  3.34it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.006', 'forward': '0.299', 'batch_size': '1', 'rtf': '0.028'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  3.34it/s]\u001b[A\n",
      "rtf_avg: 0.028: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  3.31it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.64it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.007', 'forward': '0.378', 'batch_size': '1', 'rtf': '0.026'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.64it/s]\u001b[A\n",
      "rtf_avg: 0.026: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.62it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.60it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.007', 'forward': '0.385', 'batch_size': '1', 'rtf': '0.026'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.60it/s]\u001b[A\n",
      "rtf_avg: 0.026: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.58it/s]                                                                                          \u001b[A\n",
      "rtf_avg: 0.030, time_speech:  46.440, time_escape: 1.410: 100%|\u001b[31m██████████\u001b[0m| 1/1 [00:01<00:00,  1.43s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "============>>>>\n",
      "[{'key': 'demo3', 'text': '<|zh|><|HAPPY|><|Speech|><|withitn|>你哎你好，我是芒果的，我看咱浏览华润二4层的房子了，咱是想买吗？啊，我了解一下啊嗯那咱俩加个微信呢，帮你介绍一下。 <|zh|><|HAPPY|><|Speech|><|withitn|>嗯，不用，我看了一下，就是我可以你是在那个我我可以就是那个搁跟那个什么里边跟你聊，问了问一下哪二楼完事多少层，我了解一下这个情啊。 <|zh|><|HAPPY|><|Speech|><|withitn|>哦，我知道但是你是你不是有需求吗？你想要什么样的房子，我不就可以直接发给你吗？ <|zh|><|HAPPY|><|Speech|><|withitn|>啊，没事，不用，我我不想加那么多微信。嗯，行，那好了，再见嗯。'}]\n",
      "============>>>>\n",
      "你哎你好，我是芒果的，我看咱浏览华润二4层的房子了，咱是想买吗？啊，我了解一下啊嗯那咱俩加个微信呢，帮你介绍一下。嗯，不用，我看了一下，就是我可以你是在那个我我可以就是那个搁跟那个什么里边跟你聊，问了问一下哪二楼完事多少层，我了解一下这个情啊。哦，我知道但是你是你不是有需求吗？你想要什么样的房子，我不就可以直接发给你吗？啊，没事，不用，我我不想加那么多微信。嗯，行，那好了，再见嗯。😊\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "# auto\n",
    "fileName = \"demo3\"\n",
    "res = model.generate(\n",
    "    # input=f\"{model.model_path}/example/en.mp3\",\n",
    "    input=f\"/mnt/workspace/notebook_hub_ms/{fileName}.mp3\",\n",
    "    cache={},\n",
    "    language=\"auto\",  # \"zn\", \"en\", \"yue\", \"ja\", \"ko\", \"nospeech\"\n",
    "    use_itn=True,\n",
    "    batch_size_s=60,\n",
    "    merge_vad=True,  #\n",
    "    merge_length_s=15,\n",
    ")\n",
    "print(\"============>>>>\")\n",
    "print(res)\n",
    "print(\"============>>>>\")\n",
    "text = rich_transcription_postprocess(res[0][\"text\"])\n",
    "print(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "bd62a9d6-72d8-47b8-8787-187d9812989a",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-09-24T05:38:36.291124Z",
     "iopub.status.busy": "2024-09-24T05:38:36.290787Z",
     "iopub.status.idle": "2024-09-24T05:38:36.509878Z",
     "shell.execute_reply": "2024-09-24T05:38:36.509324Z",
     "shell.execute_reply.started": "2024-09-24T05:38:36.291105Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "内容已成功写入到 /mnt/workspace/notebook_hub_ms/demo/demo3.txt\n"
     ]
    }
   ],
   "source": [
    "# 指定文件路径和要写入的字符串\n",
    "!mkdir -p /mnt/workspace/notebook_hub_ms/demo/\n",
    "file_path = f'/mnt/workspace/notebook_hub_ms/demo/{fileName}.txt'\n",
    "content = text\n",
    "\n",
    "# 使用 'w' 模式打开文件以进行写入\n",
    "with open(file_path, 'w', encoding='utf-8') as file:\n",
    "    file.write(content)\n",
    "\n",
    "print(f'内容已成功写入到 {file_path}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ea373170-8b95-4d98-b6d4-31840ef98dd4",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-09-24T05:38:51.965957Z",
     "iopub.status.busy": "2024-09-24T05:38:51.965589Z",
     "iopub.status.idle": "2024-09-24T05:38:59.723033Z",
     "shell.execute_reply": "2024-09-24T05:38:59.722548Z",
     "shell.execute_reply.started": "2024-09-24T05:38:51.965933Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "funasr version: 1.1.6.\n",
      "Check update of funasr, and it would cost few times. You may disable it by set `disable_update=True` in AutoModel\n",
      "You are using the latest version of funasr-1.1.6\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-09-24 13:38:53,084 - modelscope - INFO - Use user-specified model revision: v2.0.4\n",
      "Downloading [am.mvn]: 100%|██████████| 10.9k/10.9k [00:00<00:00, 21.4kB/s]\n",
      "Downloading [example/asr_example.wav]: 100%|██████████| 141k/141k [00:00<00:00, 335kB/s]\n",
      "Downloading [config.yaml]: 100%|██████████| 2.40k/2.40k [00:00<00:00, 6.08kB/s]\n",
      "Downloading [configuration.json]: 100%|██████████| 448/448 [00:00<00:00, 898B/s]\n",
      "Downloading [model.pt]: 100%|██████████| 151M/151M [00:01<00:00, 143MB/s]  \n",
      "Downloading [README.md]: 100%|██████████| 13.2k/13.2k [00:00<00:00, 33.5kB/s]\n",
      "Downloading [seg_dict]: 100%|██████████| 7.90M/7.90M [00:00<00:00, 13.1MB/s]\n",
      "Downloading [example/text.txt]: 100%|██████████| 43.0/43.0 [00:00<00:00, 106B/s]\n",
      "Downloading [tokens.json]: 100%|██████████| 91.5k/91.5k [00:00<00:00, 217kB/s]\n",
      "rtf_avg: 0.012: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.72it/s]                                                                                          "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'key': 'rand_key_2yW4Acq9GFz6Y', 'text': '你 哎 你 好 我 是 芒 果 的 我 看 咱 浏 览 华 润 二 4 层 的 房 子 了 咱 是 想 买 吗 啊 我 了 解 一 下 啊 嗯 那 咱 俩 加 个 微 信 呢 帮 你 介 绍 一 下 嗯 不 用 我 看 了 一 下 就 是 我 可 以 你 是 在 那 个 我 我 可 以 就 是 那 个 搁 跟 那 个 什 么 里 边 跟 你 聊 问 了 问 一 下 哪 二 楼 完 事 多 少 层 我 了 解 一 下 这 个 情 啊 哦 我 知 道 但 是 你 是 你 不 是 有 需 求 吗 你 想 要 什 么 样 的 房 子 我 不 就 可 以 直 接 发 给 你 吗 啊 没 事 不 用 我 我 不 想 加 那 么 多 微 信 嗯 行 那 好 了 再 见 嗯', 'timestamp': [[1190, 1290], [1290, 1450], [1450, 1690], [2570, 2810], [2810, 3050], [3050, 3290], [3310, 3510], [3510, 3710], [3710, 3950], [3990, 4210], [4210, 4290], [4290, 4430], [4430, 4510], [4510, 4650], [4650, 4830], [4830, 5010], [5010, 5170], [5170, 5310], [5310, 5430], [5430, 5590], [5590, 5750], [5750, 5870], [5870, 6050], [6050, 6290], [6310, 6390], [6390, 6530], [6530, 6670], [6670, 6770], [6770, 6910], [6910, 7150], [7150, 7390], [7450, 7690], [8750, 8910], [8910, 9050], [9050, 9290], [9290, 9450], [9450, 9610], [9610, 9690], [9690, 9930], [10050, 10290], [10950, 11190], [11250, 11390], [11390, 11530], [11530, 11650], [11650, 11830], [11830, 11950], [11950, 12170], [12170, 12410], [12410, 12650], [12990, 13170], [13170, 13250], [13250, 13370], [13370, 13550], [13550, 13650], [13650, 13830], [13830, 14070], [15630, 15870], [16270, 16430], [16430, 16630], [16630, 16770], [16770, 16950], [16950, 17090], [17090, 17230], [17230, 17310], [17310, 17450], [17450, 17570], [17570, 17690], [17690, 17930], [18110, 18230], [18230, 18350], [18350, 18590], [18690, 18830], [18830, 19070], [19130, 19370], [19370, 19610], [19610, 19850], [19850, 20090], [21130, 21370], [21410, 21530], [21530, 21670], [21670, 21830], [21830, 21890], [21890, 22070], [22070, 22310], [22330, 22510], [22510, 22750], [22850, 23090], [23110, 23230], [23230, 23410], [23410, 23650], [23710, 23870], [23870, 24110], [24270, 24410], [24410, 24530], [24530, 24610], [24610, 24730], [24730, 24870], [24870, 25110], [25130, 25210], [25210, 25370], [25370, 25590], [25590, 25730], [25730, 25870], [25870, 26110], [26230, 26410], [26410, 26570], [26570, 26810], [26950, 27090], [27090, 27210], [27210, 27310], [27310, 27430], [27430, 27630], [27630, 27870], [27870, 27970], [27970, 28110], [28110, 28210], [28210, 28290], [28290, 28390], [28390, 28490], [28490, 28610], [28610, 28810], [28810, 28890], [28890, 29130], [30050, 30290], [30830, 30970], [30970, 31110], [31110, 31230], [31230, 31350], [31350, 31510], [31510, 31690], [31690, 31930], [32009, 32150], [32150, 32270], [32270, 32369], [32369, 32450], [32450, 32590], [32590, 32790], [32790, 33030], [34370, 34530], [34530, 34670], [34670, 34810], [34810, 34970], [34970, 35110], [35110, 35230], [35230, 35470], [35510, 35750], [35770, 35910], [35910, 35990], [35990, 36170], [36170, 36290], [36290, 36370], [36370, 36510], [36510, 36630], [36630, 36750], [36750, 36950], [36950, 37050], [37050, 37170], [37170, 37310], [37310, 37550], [37550, 37690], [37690, 37770], [37770, 37910], [37910, 38030], [38030, 38190], [38190, 38410], [38410, 38530], [38530, 38670]]}]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "from funasr import AutoModel\n",
    "\n",
    "model_fa = AutoModel(model=\"fa-zh\", model_revision=\"v2.0.4\",\n",
    "    device=\"cuda:0\")\n",
    "wav_file = f\"/mnt/workspace/notebook_hub_ms/{fileName}.mp3\"\n",
    "text_file = f\"/mnt/workspace/notebook_hub_ms/demo/{fileName}.txt\"\n",
    "res = model_fa.generate(input=(wav_file, text_file), data_type=(\"sound\", \"text\"))\n",
    "print(res)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "146617af-4bb5-46aa-9546-892991c53b13",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-09-24T05:41:23.210684Z",
     "iopub.status.busy": "2024-09-24T05:41:23.210347Z",
     "iopub.status.idle": "2024-09-24T05:41:57.127704Z",
     "shell.execute_reply": "2024-09-24T05:41:57.127220Z",
     "shell.execute_reply.started": "2024-09-24T05:41:23.210664Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "funasr version: 1.1.6.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-09-24 13:41:23,619 - modelscope - INFO - Use user-specified model revision: v2.0.4\n",
      "Downloading [config.yaml]: 100%|██████████| 812/812 [00:00<00:00, 1.64kB/s]\n",
      "Downloading [configuration.json]: 100%|██████████| 450/450 [00:00<00:00, 886B/s]\n",
      "Downloading [jieba.c.dict]: 100%|██████████| 39.6M/39.6M [00:01<00:00, 36.8MB/s]\n",
      "Downloading [jieba_usr_dict]: 100%|██████████| 10.8M/10.8M [00:00<00:00, 13.5MB/s]\n",
      "Downloading [model.pt]: 100%|██████████| 1.05G/1.05G [00:03<00:00, 347MB/s] \n",
      "Downloading [example/punc_example.txt]: 100%|██████████| 863/863 [00:00<00:00, 1.65kB/s]\n",
      "Downloading [README.md]: 100%|██████████| 10.6k/10.6k [00:00<00:00, 27.7kB/s]\n",
      "Downloading [fig/struct.png]: 100%|██████████| 151k/151k [00:00<00:00, 300kB/s]\n",
      "Downloading [tokens.json]: 100%|██████████| 7.90M/7.90M [00:00<00:00, 11.0MB/s]\n",
      "Building prefix dict from the default dictionary ...\n",
      "DEBUG:jieba:Building prefix dict from the default dictionary ...\n",
      "Dumping model to file cache /tmp/jieba.cache\n",
      "DEBUG:jieba:Dumping model to file cache /tmp/jieba.cache\n",
      "Loading model cost 0.543 seconds.\n",
      "DEBUG:jieba:Loading model cost 0.543 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "DEBUG:jieba:Prefix dict has been built successfully.\n",
      "rtf_avg: -0.023: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00, 41.78it/s]                                                                                  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'key': 'rand_key_2yW4Acq9GFz6Y', 'text': '那今天的会就到这里吧，happy new year,明年见。', 'punc_array': tensor([1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 3])}]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "from funasr import AutoModel\n",
    "\n",
    "model_ct = AutoModel(model=\"ct-punc\",\n",
    "    model_revision=\"v2.0.4\",\n",
    "    device=\"cuda:0\",\n",
    "    disable_update=True,\n",
    "    # hub=\"hf\"\n",
    "    )\n",
    "res_ct = model_ct.generate(input=\"那今天的会就到这里吧 happy new year 明年见\")\n",
    "print(res_ct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b875d01e-0c86-40cb-9cd4-acb62fa9abac",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-09-24T05:46:37.083092Z",
     "iopub.status.busy": "2024-09-24T05:46:37.082745Z",
     "iopub.status.idle": "2024-09-24T05:46:55.476125Z",
     "shell.execute_reply": "2024-09-24T05:46:55.475459Z",
     "shell.execute_reply.started": "2024-09-24T05:46:37.083072Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "funasr version: 1.1.6.\n",
      "Check update of funasr, and it would cost few times. You may disable it by set `disable_update=True` in AutoModel\n",
      "You are using the latest version of funasr-1.1.6\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-09-24 13:46:38,559 - modelscope - INFO - Use user-specified model revision: v2.0.4\n",
      "2024-09-24 13:46:41,749 - modelscope - INFO - Use user-specified model revision: v2.0.4\n",
      "2024-09-24 13:46:42,450 - modelscope - INFO - Use user-specified model revision: v2.0.4\n",
      "2024-09-24 13:46:43,908 - modelscope - INFO - Use user-specified model revision: v2.0.2\n",
      "Downloading [campplus_cn_common.bin]: 100%|██████████| 26.7M/26.7M [00:00<00:00, 38.5MB/s]\n",
      "Downloading [config.yaml]: 100%|██████████| 537/537 [00:00<00:00, 996B/s]\n",
      "Downloading [configuration.json]: 100%|██████████| 581/581 [00:00<00:00, 1.11kB/s]\n",
      "Downloading [dingding.jpg]: 100%|██████████| 180k/180k [00:00<00:00, 350kB/s]\n",
      "Downloading [quickstart.md]: 100%|██████████| 1.49k/1.49k [00:00<00:00, 2.86kB/s]\n",
      "Downloading [README.md]: 100%|██████████| 5.86k/5.86k [00:00<00:00, 9.08kB/s]\n",
      "Downloading [examples/speaker1_a_cn_16k.wav]: 100%|██████████| 116k/116k [00:00<00:00, 215kB/s]\n",
      "Downloading [examples/speaker1_b_cn_16k.wav]: 100%|██████████| 153k/153k [00:00<00:00, 300kB/s]\n",
      "Downloading [examples/speaker2_a_cn_16k.wav]: 100%|██████████| 166k/166k [00:00<00:00, 382kB/s]\n",
      "Downloading [structure.png]: 100%|██████████| 279k/279k [00:00<00:00, 623kB/s]\n",
      "rtf_avg: 0.007: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  3.12it/s]                                                                                          \n",
      "  0%|\u001b[31m          \u001b[0m| 0/1 [00:00<?, ?it/s]\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.50it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.002', 'forward': '0.400', 'batch_size': '1', 'rtf': '0.351'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.50it/s]\u001b[A\n",
      "rtf_avg: 0.351: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.48it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.001', 'forward': '0.058', 'batch_size': '1', 'rtf': '0.039'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00, 17.15it/s]\u001b[A\n",
      "rtf_avg: 0.039: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00, 16.72it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.23it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.002', 'forward': '0.449', 'batch_size': '1', 'rtf': '0.127'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.23it/s]\u001b[A\n",
      "rtf_avg: 0.127: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.21it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/4 [00:00<?, ?it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.004', 'forward': '0.100', 'batch_size': '1', 'rtf': '0.017'}, : 100%|\u001b[34m██████████\u001b[0m| 4/4 [00:00<00:00, 39.77it/s]\u001b[A\n",
      "rtf_avg: 0.017: 100%|\u001b[34m██████████\u001b[0m| 4/4 [00:00<00:00, 39.18it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.16it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.002', 'forward': '0.464', 'batch_size': '1', 'rtf': '0.129'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.16it/s]\u001b[A\n",
      "rtf_avg: 0.129: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.14it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/4 [00:00<?, ?it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.004', 'forward': '0.074', 'batch_size': '1', 'rtf': '0.012'}, : 100%|\u001b[34m██████████\u001b[0m| 4/4 [00:00<00:00, 53.59it/s]\u001b[A\n",
      "rtf_avg: 0.012: 100%|\u001b[34m██████████\u001b[0m| 4/4 [00:00<00:00, 52.49it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.03it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.002', 'forward': '0.492', 'batch_size': '1', 'rtf': '0.104'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.03it/s]\u001b[A\n",
      "rtf_avg: 0.104: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  2.02it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/6 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 6/6 [00:00<00:00, 50.68it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.006', 'forward': '0.118', 'batch_size': '1', 'rtf': '0.013'}, : 100%|\u001b[34m██████████\u001b[0m| 6/6 [00:00<00:00, 50.68it/s]\u001b[A\n",
      "rtf_avg: 0.013: 100%|\u001b[34m██████████\u001b[0m| 6/6 [00:00<00:00, 49.43it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.98it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.002', 'forward': '0.506', 'batch_size': '1', 'rtf': '0.091'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.98it/s]\u001b[A\n",
      "rtf_avg: 0.091: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.96it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/7 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 7/7 [00:00<00:00, 55.89it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.007', 'forward': '0.125', 'batch_size': '1', 'rtf': '0.012'}, : 100%|\u001b[34m██████████\u001b[0m| 7/7 [00:00<00:00, 55.89it/s]\u001b[A\n",
      "rtf_avg: 0.012: 100%|\u001b[34m██████████\u001b[0m| 7/7 [00:00<00:00, 54.56it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.92it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.002', 'forward': '0.521', 'batch_size': '1', 'rtf': '0.091'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.92it/s]\u001b[A\n",
      "rtf_avg: 0.091: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.91it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/7 [00:00<?, ?it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.007', 'forward': '0.096', 'batch_size': '1', 'rtf': '0.009'}, : 100%|\u001b[34m██████████\u001b[0m| 7/7 [00:00<00:00, 72.08it/s]\u001b[A\n",
      "rtf_avg: 0.009: 100%|\u001b[34m██████████\u001b[0m| 7/7 [00:00<00:00, 70.90it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.84it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.003', 'forward': '0.544', 'batch_size': '1', 'rtf': '0.064'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.84it/s]\u001b[A\n",
      "rtf_avg: 0.064: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.83it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/11 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 11/11 [00:00<00:00, 73.22it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.010', 'forward': '0.150', 'batch_size': '1', 'rtf': '0.009'}, : 100%|\u001b[34m██████████\u001b[0m| 11/11 [00:00<00:00, 73.22it/s]\u001b[A\n",
      "rtf_avg: 0.009: 100%|\u001b[34m██████████\u001b[0m| 11/11 [00:00<00:00, 71.85it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.77it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.003', 'forward': '0.566', 'batch_size': '1', 'rtf': '0.058'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.77it/s]\u001b[A\n",
      "rtf_avg: 0.058: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00,  1.76it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/13 [00:00<?, ?it/s]\u001b[A\n",
      "100%|\u001b[34m██████████\u001b[0m| 13/13 [00:00<00:00, 76.45it/s]\u001b[A\n",
      "{'load_data': '0.000', 'extract_feat': '0.012', 'forward': '0.170', 'batch_size': '1', 'rtf': '0.009'}, : 100%|\u001b[34m██████████\u001b[0m| 13/13 [00:00<00:00, 76.45it/s]\u001b[A\n",
      "rtf_avg: 0.009: 100%|\u001b[34m██████████\u001b[0m| 13/13 [00:00<00:00, 75.12it/s]                                                                                          \u001b[A\n",
      "\n",
      "  0%|\u001b[34m          \u001b[0m| 0/1 [00:00<?, ?it/s]\u001b[A\n",
      "{'load_data': 0.0, 'extract_feat': 0.0, 'forward': '0.053', 'batch_size': '1', 'rtf': '-0.053'}, : 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00, 18.28it/s]\u001b[A\n",
      "rtf_avg: -0.053: 100%|\u001b[34m██████████\u001b[0m| 1/1 [00:00<00:00, 16.04it/s]                                                                                  \u001b[A\n",
      "rtf_avg: 0.109, time_speech:  46.440, time_escape: 5.077: 100%|\u001b[31m██████████\u001b[0m| 1/1 [00:05<00:00,  5.10s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'key': 'demo3', 'text': '干啥呢？你好哎，你好，我是芒果的，我看咱浏览华润二十四层的房子了，咱是想买吗？啊，我了解一下啊，嗯那咱俩加个微信呢，帮你介绍一下。嗯，不用，我看了一下，就是我可以，你是你在那个我我可以就是那个搁搁那个什么里边跟你聊问了，问一下哪二楼完事多少层，我了解一下这个情况哦，我知道，但是你加一下这个啊，你不是有需求吗？你想要什么样的房子，我不就可以直接发给你吗？啊，没事，不用我，我不想加，那我的微信。嗯，行，那好了再见嗯。', 'timestamp': [[680, 840], [840, 1020], [1020, 1260], [1260, 1380], [1380, 1620], [2500, 2740], [2780, 2940], [2940, 3180], [3340, 3480], [3480, 3720], [3760, 3880], [3880, 4120], [4240, 4420], [4420, 4500], [4500, 4600], [4600, 4800], [4800, 4960], [4960, 5200], [5200, 5320], [5320, 5480], [5480, 5580], [5580, 5660], [5660, 5760], [5760, 5900], [5900, 6060], [6060, 6300], [6320, 6500], [6500, 6640], [6640, 6740], [6740, 6860], [6860, 7040], [7040, 7280], [7320, 7560], [8640, 8880], [8880, 9040], [9040, 9240], [9240, 9460], [9460, 9600], [9600, 9840], [9900, 10195], [10860, 11100], [11240, 11440], [11440, 11540], [11540, 11660], [11660, 11820], [11820, 11960], [11960, 12180], [12180, 12340], [12340, 12580], [12960, 13180], [13180, 13320], [13320, 13460], [13460, 13640], [13640, 13760], [13760, 14055], [15630, 15870], [16270, 16410], [16410, 16630], [16630, 16790], [16790, 16990], [16990, 17130], [17130, 17230], [17230, 17410], [17410, 17570], [17570, 17650], [17650, 17890], [18070, 18250], [18250, 18390], [18390, 18630], [18650, 18810], [18810, 19050], [19270, 19510], [19590, 19730], [19730, 20115], [21150, 21390], [21470, 21590], [21590, 21690], [21690, 21870], [21870, 21990], [21990, 22230], [22330, 22470], [22470, 22710], [22810, 23050], [23070, 23270], [23270, 23370], [23370, 23610], [23690, 23830], [23830, 24070], [24290, 24430], [24430, 24630], [24630, 24710], [24710, 24790], [24790, 25030], [25210, 25330], [25330, 25570], [25570, 25730], [25730, 25850], [25850, 26090], [26170, 26390], [26390, 26510], [26510, 26750], [26950, 27110], [27110, 27330], [27330, 27450], [27450, 27570], [27570, 27810], [27870, 27970], [27970, 28110], [28110, 28230], [28230, 28310], [28310, 28410], [28410, 28530], [28530, 28610], [28610, 28770], [28770, 29095], [29950, 30190], [30790, 30990], [30990, 31130], [31130, 31370], [31530, 31650], [31650, 31870], [31870, 32030], [32030, 32170], [32170, 32370], [32370, 32530], [32530, 32690], [32690, 32975], [33910, 34150], [34370, 34550], [34550, 34650], [34650, 34830], [34830, 35030], [35030, 35250], [35250, 35490], [35490, 35730], [35790, 35950], [35950, 36130], [36130, 36250], [36250, 36370], [36370, 36490], [36490, 36610], [36610, 36730], [36730, 36950], [36950, 37070], [37070, 37190], [37190, 37310], [37310, 37550], [37590, 37730], [37730, 37850], [37850, 37950], [37950, 38110], [38110, 38350], [38370, 38610], [38610, 38730], [38730, 39025], [40580, 40820], [40820, 40980], [40980, 41200], [41200, 41340], [41340, 41580], [41580, 41740], [41740, 41880], [41880, 41980], [41980, 42160], [42160, 42340], [42340, 42440], [42440, 42540], [42540, 42700], [42700, 42800], [42800, 43040], [43500, 43740], [43840, 44040], [44040, 44180], [44180, 44280], [44280, 44420], [44420, 44520], [44520, 44815], [45430, 45955]], 'sentence_info': [{'text': '干啥呢？', 'start': 680, 'end': 1260, 'timestamp': [[680, 840], [840, 1020], [1020, 1260]], 'spk': 0}, {'text': '你好哎，', 'start': 1260, 'end': 2740, 'timestamp': [[1260, 1380], [1380, 1620], [2500, 2740]], 'spk': 1}, {'text': '你好，', 'start': 2780, 'end': 3180, 'timestamp': [[2780, 2940], [2940, 3180]], 'spk': 1}, {'text': '我是芒果的，', 'start': 3340, 'end': 4420, 'timestamp': [[3340, 3480], [3480, 3720], [3760, 3880], [3880, 4120], [4240, 4420]], 'spk': 1}, {'text': '我看咱浏览华润二十四层的房子了，', 'start': 4420, 'end': 6640, 'timestamp': [[4420, 4500], [4500, 4600], [4600, 4800], [4800, 4960], [4960, 5200], [5200, 5320], [5320, 5480], [5480, 5580], [5580, 5660], [5660, 5760], [5760, 5900], [5900, 6060], [6060, 6300], [6320, 6500], [6500, 6640]], 'spk': 1}, {'text': '咱是想买吗？', 'start': 6640, 'end': 7560, 'timestamp': [[6640, 6740], [6740, 6860], [6860, 7040], [7040, 7280], [7320, 7560]], 'spk': 1}, {'text': '啊，', 'start': 8640, 'end': 8880, 'timestamp': [[8640, 8880]], 'spk': 0}, {'text': '我了解一下啊，', 'start': 8880, 'end': 10195, 'timestamp': [[8880, 9040], [9040, 9240], [9240, 9460], [9460, 9600], [9600, 9840], [9900, 10195]], 'spk': 0}, {'text': '嗯那咱俩加个微信呢，', 'start': 10860, 'end': 12580, 'timestamp': [[10860, 11100], [11240, 11440], [11440, 11540], [11540, 11660], [11660, 11820], [11820, 11960], [11960, 12180], [12180, 12340], [12340, 12580]], 'spk': 1}, {'text': '帮你介绍一下。', 'start': 12960, 'end': 14055, 'timestamp': [[12960, 13180], [13180, 13320], [13320, 13460], [13460, 13640], [13640, 13760], [13760, 14055]], 'spk': 1}, {'text': '嗯，', 'start': 15630, 'end': 15870, 'timestamp': [[15630, 15870]], 'spk': 0}, {'text': '不用，', 'start': 16270, 'end': 16630, 'timestamp': [[16270, 16410], [16410, 16630]], 'spk': 0}, {'text': '我看了一下，', 'start': 16630, 'end': 17410, 'timestamp': [[16630, 16790], [16790, 16990], [16990, 17130], [17130, 17230], [17230, 17410]], 'spk': 0}, {'text': '就是我可以，', 'start': 17410, 'end': 18390, 'timestamp': [[17410, 17570], [17570, 17650], [17650, 17890], [18070, 18250], [18250, 18390]], 'spk': 0}, {'text': '你是你在那个我我可以就是那个搁搁那个什么里边跟你聊问了，', 'start': 18390, 'end': 25570, 'timestamp': [[18390, 18630], [18650, 18810], [18810, 19050], [19270, 19510], [19590, 19730], [19730, 20115], [21150, 21390], [21470, 21590], [21590, 21690], [21690, 21870], [21870, 21990], [21990, 22230], [22330, 22470], [22470, 22710], [22810, 23050], [23070, 23270], [23270, 23370], [23370, 23610], [23690, 23830], [23830, 24070], [24290, 24430], [24430, 24630], [24630, 24710], [24710, 24790], [24790, 25030], [25210, 25330], [25330, 25570]], 'spk': 0}, {'text': '问一下哪二楼完事多少层，', 'start': 25570, 'end': 27810, 'timestamp': [[25570, 25730], [25730, 25850], [25850, 26090], [26170, 26390], [26390, 26510], [26510, 26750], [26950, 27110], [27110, 27330], [27330, 27450], [27450, 27570], [27570, 27810]], 'spk': 0}, {'text': '我了解一下这个情况哦，', 'start': 27870, 'end': 30190, 'timestamp': [[27870, 27970], [27970, 28110], [28110, 28230], [28230, 28310], [28310, 28410], [28410, 28530], [28530, 28610], [28610, 28770], [28770, 29095], [29950, 30190]], 'spk': 0}, {'text': '我知道，', 'start': 30790, 'end': 31370, 'timestamp': [[30790, 30990], [30990, 31130], [31130, 31370]], 'spk': 0}, {'text': '但是你加一下这个啊，', 'start': 31530, 'end': 34150, 'timestamp': [[31530, 31650], [31650, 31870], [31870, 32030], [32030, 32170], [32170, 32370], [32370, 32530], [32530, 32690], [32690, 32975], [33910, 34150]], 'spk': 0}, {'text': '你不是有需求吗？', 'start': 34370, 'end': 35730, 'timestamp': [[34370, 34550], [34550, 34650], [34650, 34830], [34830, 35030], [35030, 35250], [35250, 35490], [35490, 35730]], 'spk': 1}, {'text': '你想要什么样的房子，', 'start': 35790, 'end': 37070, 'timestamp': [[35790, 35950], [35950, 36130], [36130, 36250], [36250, 36370], [36370, 36490], [36490, 36610], [36610, 36730], [36730, 36950], [36950, 37070]], 'spk': 1}, {'text': '我不就可以直接发给你吗？', 'start': 37070, 'end': 39025, 'timestamp': [[37070, 37190], [37190, 37310], [37310, 37550], [37590, 37730], [37730, 37850], [37850, 37950], [37950, 38110], [38110, 38350], [38370, 38610], [38610, 38730], [38730, 39025]], 'spk': 1}, {'text': '啊，', 'start': 40580, 'end': 40820, 'timestamp': [[40580, 40820]], 'spk': 0}, {'text': '没事，', 'start': 40820, 'end': 41200, 'timestamp': [[40820, 40980], [40980, 41200]], 'spk': 0}, {'text': '不用我，', 'start': 41200, 'end': 41740, 'timestamp': [[41200, 41340], [41340, 41580], [41580, 41740]], 'spk': 0}, {'text': '我不想加，', 'start': 41740, 'end': 42340, 'timestamp': [[41740, 41880], [41880, 41980], [41980, 42160], [42160, 42340]], 'spk': 0}, {'text': '那我的微信。', 'start': 42340, 'end': 43040, 'timestamp': [[42340, 42440], [42440, 42540], [42540, 42700], [42700, 42800], [42800, 43040]], 'spk': 0}, {'text': '嗯，', 'start': 43500, 'end': 43740, 'timestamp': [[43500, 43740]], 'spk': 0}, {'text': '行，', 'start': 43840, 'end': 44040, 'timestamp': [[43840, 44040]], 'spk': 0}, {'text': '那好了再见嗯。', 'start': 44040, 'end': 45955, 'timestamp': [[44040, 44180], [44180, 44280], [44280, 44420], [44420, 44520], [44520, 44815], [45430, 45955]], 'spk': 0}]}]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "# from funasr import AutoModel\n",
    "# paraformer-zh is a multi-functional asr model\n",
    "# use vad, punc, spk or not as you need\n",
    "model_pf = AutoModel(model=\"paraformer-zh\", model_revision=\"v2.0.4\",\n",
    "                  vad_model=\"fsmn-vad\", vad_model_revision=\"v2.0.4\",\n",
    "                  punc_model=\"ct-punc-c\", punc_model_revision=\"v2.0.4\",\n",
    "                  spk_model=\"cam++\", spk_model_revision=\"v2.0.2\",\n",
    "                  # device=\"cuda:0\",hub=\"hf\"\n",
    "                  )\n",
    "res = model_pf.generate(input=f\"/mnt/workspace/notebook_hub_ms/{fileName}.mp3\",\n",
    "                     batch_size_s=300,\n",
    "                     hotword='魔搭')\n",
    "print(res)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
